function [combos_all_unique] = combinations_2(m_regr,J)

m_regr_x = m_regr(1:J);
m_x = m_regr_x+1;

temp = cell(length(m_regr_x),1);
for i=1:length(m_regr_x)
    
    temp{i} = 1:m_regr_x(length(m_regr_x)-i+1)+1;
    
end
combos_x = allcomb(temp{:});     
combos_x = combos_x(:,[length(m_regr_x):-1:1]);       % key is that the index that moves "faster" is in the first column, then second one, and so on
                                            % (has to be consistent with order of theta)

                                           
mat = sort(combos_x(:,2:end),2);

combos_x_reord = [combos_x(:,1) mat];

[~,ia] = unique(combos_x_reord,'stable','rows');

combos_x_reord_unique = combos_x(ia,:);

combos_z = combos_x;

combos_all_unique = zeros(size(combos_x_reord_unique,1)*size(combos_z,1),2*J);
                                            
for zz=1:size(combos_z,1)
    for xx=1:size(combos_x_reord_unique,1)
        
        temp1 = combos_x_reord_unique(xx,:);
        temp2 = combos_z(zz,:);
        
        ii = (zz-1)*size(combos_x_reord_unique,1) + xx;
        
        combos_all_unique(ii,:) = [temp1 temp2];
        %ii
    end
end
                                            


end